
import '../config/app_url_address.dart';
import 'dio_request.dart';

class ApiManager {


  static Future getCategoryProduct(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.getBloc(joysearchCategoryProductAPI,parameter: parameter,easyLoading: true, success: success, fail: fail);
  }

  static Future getHomeBannerAndProduct(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.getBloc(joygetHomeDataAPI,parameter: parameter,easyLoading: true, success: success, fail: fail);
  }

  static Future getHotProductList(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.getBloc(joyhotProduct,parameter: parameter,easyLoading: true, success: success, fail: fail);
  }

  static Future getHomeCategory(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.getBloc(joygetHomeCategoryAPI,parameter: parameter,easyLoading: true, success: success, fail: fail);
  }

  static Future postLoginUser(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.postBloc(joypostLoginAPI,parameter: parameter,easyLoading: true, success: success, fail: fail);
  }

  static Future postLoginOutUser(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.postBloc(joyloginOut,parameter: parameter,easyLoading: true, success: success, fail: fail);
  }

  static Future getProductDetail(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.getBloc(joyproductDetailurl,parameter: parameter,easyLoading: true, success: success, fail: fail);
  }


  static Future getsearchKey(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.getBloc(joysearchKeyListurl,parameter: parameter,easyLoading: true, success: success, fail: fail);
  }


  /// 上传图片
  static Future postUploadFile(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.PostFile(uploadFile, parameter: parameter, easyLoading: true, success: success, fail: fail);
  }

  /// 图片图片搜索（使用表单提交）
  static Future getSearchSimilarityImage(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    // 🔥 使用PostFile方法进行表单提交（multipart/form-data）
    return DioRequest.instance.PostFile(newSearchImage, parameter: parameter, easyLoading: true, success: success, fail: fail);
  }

  /// 图片图片搜索
  static Future getSearchImage(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.postBloc(searchImage, parameter: parameter, easyLoading: true, success: success, fail: fail);
  }

  /// 判断是否收藏
  static Future getProductIsCollected(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.postBloc(isCollection, parameter: parameter, easyLoading: true, success: success, fail: fail);
  }

  /// 添加收藏
  static Future postAddProductCollected(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.postBloc(AddCollection, parameter: parameter, easyLoading: true, success: success, fail: fail);
  }

  /// 收藏列表
  static Future getProductCollectedList(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.postBloc(collectionList, parameter: parameter, easyLoading: true, success: success, fail: fail);
  }


  /// 打点用户浏览数据
  static Future addUserBrowseProduct(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.postBloc(addUserRecord, parameter: parameter, easyLoading: true, success: success, fail: fail);
  }


  /// 获取用户浏览数据
  static Future getUserBrowseProduct(
      Map<String, dynamic> parameter, {
        CallbackSuccess? success,
        CallbackFail? fail,
      }) async {
    return DioRequest.instance.postBloc(getUserBrowse, parameter: parameter, easyLoading: true, success: success, fail: fail);
  }

}